#define DEBUG
#include <cstdio>
#include <cstring>

using namespace std;

const int maxn=2000;

class BiGraph {
public:
  int n, m, ind[maxn+1], to[maxn*maxn+1], link[maxn*maxn+1], b[maxn+1];

  void addSide(int u, int v) {
    m++;
    to[m] = v;
    link[m] = ind[u];
    ind[u] = m;
  }

  bool check(int o, bool *book) {
    for (int i=ind[o]; i; i=link[i]) {
      if (!b[to[i]]) {
	b[to[i]] = o;
	return true;
      } else if (!book[to[i]]) {
	book[to[i]] = true;
	if (check(b[to[i]], book)) {
	  b[to[i]] = o;
	  return true;
	}
      }
    }
    return false;
  }

  int solve() {
    static bool book[maxn+1];
    int ans=0;
    for (int i=1; i<=n; i++) {
      memset(book, 0, sizeof(book));
      ans += check(i, book);
    }
    return ans;
  }
};

int main() {
  freopen("dream.in", "r", stdin);
  freopen("dream.out", "w", stdout);

  static BiGraph bg;
  static int l[maxn+1], r[maxn+1], t[maxn+1];
  int n, m;
  scanf("%d %d", &n, &m);
  bg.n = n;
  for (int i=1; i<=n; i++) {
    scanf("%d %d", l+i, r+i);
  }
  for (int i=1; i<=m; i++) {
    scanf("%d", t+i);
    for (int j=1; j<=n; j++) {
      if (l[j]<=t[i] && r[j]>=t[i]) {
	bg.addSide(j, i);
      }
    }
  }

  printf("%d", bg.solve());

  fclose(stdin);
  fclose(stdout);
  return 0;
}
